package com.allwees.bs.core.model.user.constant;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.allwees.core.common.constant.EPlatform;
import lombok.NoArgsConstructor;

/**
 * 用户注册类型
 *
 * @author yangylsky
 * @since 2019-10-28
 *
 */
@NoArgsConstructor
public enum EUserSourceType implements IEnum<String> {
	IOS(EPlatform.IOS) {
		@Override
		public boolean isApp() {
			return true;
		}
	},

	ANDROID(EPlatform.ANDROID) {
		@Override
		public boolean isApp() {
			return true;
		}
	},

	/**
	 * IOS_OAUTH2
	 */
	IOS_O(EPlatform.IOS) {
		@Override
		public boolean isApp() {
			return true;
		}
	},

	/**
	 * ANDROID_OAUTH2
	 */
	ANDROID_O(EPlatform.ANDROID) {
		@Override
		public boolean isApp() {
			return true;
		}
	},

	PC(EPlatform.PC),

	H5(EPlatform.H5),

	/**
	 * ICS
	 */
	ICS,

	/**
	 * 测试用户
	 */
	TESTCASE(EPlatform.TESTCASE),

	/**
	 * 虚拟用户
	 */
	MOCK(null);

	private EPlatform platform;

	EUserSourceType(EPlatform platform) {
		this.platform = platform;
	}

	EPlatform platform() {
		return platform;
	}

	public boolean isApp() {
		return false;
	}

	@Override
	public String getValue(){
		return name();
	}

	public static EUserSourceType of(EPlatform platform) {
		return platform == null ? null : EUserSourceType.valueOf(platform.name());
	}
}
